<?php


namespace app\voip\func;


use app\voip\model\EDataUse;

class DataUseFunc
{
    /**
     * @param $data
     * @return mixed
     * @throws \think\exception\DbException
     */
    static function checkSave($data)
    {
        $resultData=[];
        foreach ($data as $key=>$val)
        {
            $res=EDataUse::get(['name'=>$val]);
            if ($res){
                $resultData[$val]=$res->id;
            }else{
                $res=EDataUse::create(['name'=>$val]);
                $resultData[$val]=$res->id;
            }
        }
        return $resultData;
    }
}